*********************************************************************************
*** Appendix A6
*********************************************************************************

* Project: 	International threats and European defense
* Authors: 	Matthias Mader
* Date:		March 2023	

* Data: VW Project, Pane-European survey (W1)

*********************************************************************************

*** Setup

	clear
	set more off            						// Disable partitioned output
	set dp period									// Use comma instead of dot for decimals
	set linesize 80         						// Line size limit to make output more readable
	macro drop _all         						// clear all macros
	set scheme plotplainblind, permanent				// set graph scheme, e.g., cleanplots, plottig, plotplainblind, burd3, s1mono
	graph set window fontface "Times New Roman"		// set font in graphs | "Arial" | "Times New Roman"


*** Text: correlation of threat subdimensions
	
	use DATA_clean, clear

	pwcorr threat_ind4 threat_ind5
	bysort QCOUNTRY: pwcorr threat_ind4 threat_ind5


*** Figure A6.1 (Threat perception A: Russia and China only)
	
	use DATA_clean, clear

	*Main effect of threat perceptions
	reg csdp_wouldlike c.threat_ind4 i.idconfig2 i.QCOUNTRY female age ib2.education iso comp mili
	estimates store m1
	margins, at(threat_ind4=(0 (.025) 1))
	marginsplot,  ///
		name(g1_A, replace) ///
		recast(scatter) ///
		plotopts(mcolor(none))  ///
		ciopts(recast(rbar) barwidth(0.01)) ///
		xtitle("Threat perception A", size(large)) xscale(range(0 1)) xlabel(0 (0.2) 1, labsize(large)) ///	
		ytitle("Support for integration", size(large)) yscale(range(0 1)) ylabel(0 (0.2) 1, labsize(large)) ///	
		title("  ") ///
		legend(off)

	*Support for European defence and security integration, by threat perception and EU attitude
	reg csdp_wouldlike c.threat_ind4##i.idconfig2 i.QCOUNTRY female age ib2.education iso comp mili
	estimates store m2
	margins, at(threat_ind4=(0 (.025) 1) idconfig2=(1 2))
	marginsplot,  ///
		name(g2_A, replace) ///
		recast(scatter) ///
		plot1opts(mcolor(none)) plot2opts(mcolor(none)) ///
		text(0.80 -0.01 "Inclusive identity", color(gs9) place(right) size(large)) ///
		text(0.45 -0.01  "Exclusive national identity", color(gs0) place(right) size(large)) ///
		ciopts(recast(rbar) barwidth(0.01)) ///
		xtitle("Threat perception A", size(large)) xscale(range(0 1)) xlabel(0 (0.2) 1, labsize(large)) ///	
		ytitle("Support for integration", size(large)) yscale(range(0 1)) ylabel(0 (0.2) 1, labsize(large)) ///	
		title("  ") ///
		legend(off)


	*Support for European defence and security integration among among politically unsophisticated, by threat perception and EU attitude
	reg csdp_wouldlike c.threat_ind4##i.idconfig2##c.quizr i.QCOUNTRY female age ib2.education iso comp mili
	estimates store m3
	margins, at(threat_ind4=(0 (.025) 1) idconfig2=(1 2) quizr=(0))
	marginsplot,  ///
		name(g3_A, replace) ///
		recast(scatter) ///
		plot1opts(mcolor(none)) plot2opts(mcolor(none)) ///
		text(0.83 -0.01 "Inclusive identity", color(gs9) place(right) size(large)) ///
		text(0.45 -0.01  "Exclusive national identity", color(gs0) place(right) size(large)) ///
		ciopts(recast(rbar) barwidth(0.01)) ///
		xtitle("Threat perception A", size(large)) xscale(range(0 1)) xlabel(0 (0.2) 1, labsize(large)) ///	
		ytitle("Support for integration", size(large)) yscale(range(0 1)) ylabel(0 (0.2) 1, labsize(large)) ///	
		title("LOW SOPHISTICATION", size(large)) ///
		legend(off)


	*Support for European defence and security integration among politically sophisticated, by threat perception and EU attitude
	reg csdp_wouldlike c.threat_ind4##i.idconfig2##c.quizr i.QCOUNTRY female age ib2.education iso comp mili // (same as above)
	margins, at(threat_ind4=(0 (.025) 1) idconfig2=(1 2) quizr=(1))
	marginsplot,  ///
		name(g4_A, replace) ///
		recast(scatter) ///
		plot1opts(mcolor(none)) plot2opts(mcolor(none)) ///
		text(0.85 -0.01 "Inclusive identity", color(gs9) place(right) size(large)) ///
		text(0.43 -0.01  "Exclusive national identity", color(gs0) place(right) size(large)) ///
		ciopts(recast(rbar) barwidth(0.01)) ///
		xtitle("Threat perception A", size(large)) xscale(range(0 1)) xlabel(0 (0.2) 1, labsize(large)) ///	
		ytitle("Support for integration", size(large)) yscale(range(0 1)) ylabel(0 (0.2) 1, labsize(large)) ///	
		title("HIGH SOPHISTICATION", size(large)) ///
		legend(off)



*** Figure A6.1 (Threat perception B: Terrorism, cyber, election mingling)
	
	use DATA_clean, clear

	*Main effect of threat perceptions
	reg csdp_wouldlike c.threat_ind5 i.idconfig2 i.QCOUNTRY female age ib2.education iso comp mili
	estimates store m1
	margins, at(threat_ind5=(0 (.025) 1))
	marginsplot,  ///
		name(g1_B, replace) ///
		recast(scatter) ///
		plotopts(mcolor(none))  ///
		ciopts(recast(rbar) barwidth(0.01)) ///
		xtitle("Threat perception B", size(large)) xscale(range(0 1)) xlabel(0 (0.2) 1, labsize(large)) ///	
		ytitle("Support for integration", size(large)) yscale(range(0 1)) ylabel(0 (0.2) 1, labsize(large)) ///	
		title("  ") ///
		legend(off)


	*Support for European defence and security integration, by threat perception and EU attitude
	reg csdp_wouldlike c.threat_ind5##i.idconfig2 i.QCOUNTRY female age ib2.education iso comp mili
	estimates store m2
	margins, at(threat_ind5=(0 (.025) 1) idconfig2=(1 2))
	marginsplot,  ///
		name(g2_B, replace) ///
		recast(scatter) ///
		plot1opts(mcolor(none)) plot2opts(mcolor(none)) ///
		text(0.80 -0.01 "Inclusive identity", color(gs9) place(right) size(large)) ///
		text(0.45 -0.01  "Exclusive national identity", color(gs0) place(right) size(large)) ///
		ciopts(recast(rbar) barwidth(0.01)) ///
		xtitle("Threat perception B", size(large)) xscale(range(0 1)) xlabel(0 (0.2) 1, labsize(large)) ///	
		ytitle("Support for integration", size(large)) yscale(range(0 1)) ylabel(0 (0.2) 1, labsize(large)) ///	
		title("  ") ///
		legend(off)


	*Support for European defence and security integration among among politically unsophisticated, by threat perception and EU attitude
	reg csdp_wouldlike c.threat_ind5##i.idconfig2##c.quizr i.QCOUNTRY female age ib2.education iso comp mili
	estimates store m3
	margins, at(threat_ind5=(0 (.025) 1) idconfig2=(1 2) quizr=(0))
	marginsplot,  ///
		name(g3_B, replace) ///
		recast(scatter) ///
		plot1opts(mcolor(none)) plot2opts(mcolor(none)) ///
		text(0.83 -0.01 "Inclusive identity", color(gs9) place(right) size(large)) ///
		text(0.45 -0.01  "Exclusive national identity", color(gs0) place(right) size(large)) ///
		ciopts(recast(rbar) barwidth(0.01)) ///
		xtitle("Threat perception B", size(large)) xscale(range(0 1)) xlabel(0 (0.2) 1, labsize(large)) ///	
		ytitle("Support for integration", size(large)) yscale(range(0 1)) ylabel(0 (0.2) 1, labsize(large)) ///	
		title("LOW SOPHISTICATION", size(large)) ///
		legend(off)


	*Support for European defence and security integration among politically sophisticated, by threat perception and EU attitude
	reg csdp_wouldlike c.threat_ind5##i.idconfig2##c.quizr i.QCOUNTRY female age ib2.education iso comp mili // (same as above)
	margins, at(threat_ind5=(0 (.025) 1) idconfig2=(1 2) quizr=(1))
	marginsplot,  ///
		name(g4_B, replace) ///
		recast(scatter) ///
		plot1opts(mcolor(none)) plot2opts(mcolor(none)) ///
		text(0.85 -0.01 "Inclusive identity", color(gs9) place(right) size(large)) ///
		text(0.43 -0.01  "Exclusive national identity", color(gs0) place(right) size(large)) ///
		ciopts(recast(rbar) barwidth(0.01)) ///
		xtitle("Threat perception B", size(large)) xscale(range(0 1)) xlabel(0 (0.2) 1, labsize(large)) ///	
		ytitle("Support for integration", size(large)) yscale(range(0 1)) ylabel(0 (0.2) 1, labsize(large)) ///	
		title("HIGH SOPHISTICATION", size(large)) ///
		legend(off)

